package com.skb.core.dao;

import com.skb.core.model.CommissionRate;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.io.Serializable;

@Repository("commissionRateDao")
public class CommissionRateDaoImpl implements CommissionRateDao {

    @Autowired
    private SessionFactory sessionFactory;

    @Override
    public CommissionRate create(CommissionRate commissionRate) {
        sessionFactory.getCurrentSession().persist(commissionRate);
        return commissionRate;
    }

    @Override
    public CommissionRate get(Serializable id) {
        return (CommissionRate) sessionFactory.getCurrentSession().get(CommissionRate.class, id);
    }

    @Override
    public CommissionRate update(CommissionRate commissionRate) {
        sessionFactory.getCurrentSession().update(commissionRate);
        return commissionRate;
    }

    @Override
    public void delete(CommissionRate commissionRate) {
        sessionFactory.getCurrentSession().delete(commissionRate);
    }
}
